Skip to content

#47: Add lcm(a, b) to the math module - #48

Merged
clockgrove-pendulum[bot] merged 1 commit into
mainfrom
pendulum/47
Nov 18, 2026
Merged

clockgrove-pendulum[bot] merged 1 commit into
mainfrom
pendulum/47

Conversation

@clockgrove-pendulum

@clockgrove-pendulum clockgrove-pendulum Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged in 3 min 50 s · $0.52

Issue #47 → PR #48 · merged through your merge queue at 3:37 PM PST · billed to your API key

Acceptance

Entry Change Proof
src/math.mjs exports lcm(a, b): non-negative least common multiple, sign-insensitive, 0 when either argument is 0, RangeError for non-integers; existing exports unchanged src/math.mjs (new lcm appended; no existing function touched) test/math.test.mjs, test lcm
A test under test/ imports lcm from ../src/math.mjs and checks lcm(4, 6) === 12, lcm(-4, 6) === 12, lcm(0, 5) === 0, lcm(7, 1) === 7, and that lcm(2.5, 4) throws RangeError test/math.test.mjs (import extended; new lcm test also covers lcm(4, -6), lcm(5, 0), lcm(4, 2.5)) test/math.test.mjs, test lcm
npm test passes, existing tests included — npm test: 19 tests, 19 pass
README.md documents lcm(a, b) in the same style, with a usage example and the RangeError case README.md (new entry after gcd) Reviewed by reading; matches the factorial/gcd entries

Validation

  • npm test: pass (19 tests, 0 failures).
  • Budget command: none on the task card.

Fake-only proofs

none

Assumptions

  1. lcm is computed as |a / gcd(a, b) * b| using the existing gcd export; dividing first keeps intermediate values small.
  2. lcm(0, 0) returns 0 (the issue says 0 when either argument is 0), and the result is never -0.
  3. Non-integer means !Number.isInteger(x), so NaN, Infinity and non-number values also throw RangeError, matching factorial's check.
  4. The test is added to the existing test/math.test.mjs, which already imports from ../src/math.mjs, rather than a new file.
  5. The items are small enough that the worker session wrote them directly instead of spawning implementer sub-agents.

Undone

Nothing.

🤖 Generated with Claude Code

Closes #47

Checklist items 1 and 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clockgrove-pendulum

Copy link
Copy Markdown
Contributor Author

Pendulum: cb0f274 goes to the review while its required checks run; the review stage waits for them beside its reviewer.

@clockgrove-pendulum
clockgrove-pendulum Bot marked this pull request as ready for review November 18, 2026 23:35
@clockgrove-pendulum clockgrove-pendulum Bot added the pendulum:review Applied by the Pendulum App to trigger the review job label Nov 18, 2026
@clockgrove-pendulum

Copy link
Copy Markdown
Contributor Author

Pendulum: validation green on cb0f274; ready for the reviewer.

@clockgrove-pendulum clockgrove-pendulum Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pendulum reviewer: one comment-only pass, 1 comment(s).

Acceptance as the reviewer judged it:

  • 1: met (lcm is exported at line 128: it throws RangeError when either argument fails Number.isInteger, returns 0 when either is 0, and otherwise returns Math.abs((a / gcd(a, b)) * b), which is non-negative and sign-insensitive. The diff only appends to src/math.mjs, so the existing ex…
  • 2: met (Line 3 imports lcm from ../src/math.mjs, and the lcm test at lines 140-148 asserts exact values for lcm(4, 6) === 12, lcm(-4, 6) === 12, lcm(0, 5) === 0, lcm(7, 1) === 7 and that lcm(2.5, 4) throws RangeError, all against the real function.)
  • 3: met (I ran npm test on the PR head: 19 tests, 19 pass, 0 fail. The diff removes or loosens no existing assertion; the only changed existing line is the import, which adds lcm.)
  • 4: met (Line 126 adds one It also exports lcm(a, b)... paragraph in the same form as the factorial and gcd entries, states the RangeError case for non-integers, and is followed by a usage example (lcm(4, 6); // 12) at lines 128-131.)

Comment thread README.md Resolved
@clockgrove-pendulum clockgrove-pendulum Bot removed the pendulum:review Applied by the Pendulum App to trigger the review job label Nov 18, 2026
@clockgrove-pendulum

Copy link
Copy Markdown
Contributor Author

Pendulum: cb0f274 is reviewed and validated; it merges once its required checks are green.

@clockgrove-pendulum
clockgrove-pendulum Bot added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit aca32a2 Nov 18, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add lcm(a, b) to the math module

0 participants